package com.hopu.mcshipin.controller;

import com.hopu.mcshipin.entity.R;
import com.hopu.mcshipin.entity.VideoExt;
import com.hopu.mcshipin.service.VideoListService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("videoList")
public class VideoListController {

    @Resource
    private VideoListService videoListService;

    @GetMapping("getVideoList")
    public R getVideoList(){
        try {
            // 调用服务层方法获取数据
            List<VideoExt> videoList = videoListService.getVedioList();
            // 将数据放入响应对象并返回
            return R.ok("videoList", videoList);
        } catch (Exception e) {
            // 处理异常并返回错误信息
            return R.err("获取视频列表失败: " + e.getMessage());
        }
    }
}
